import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import store from '../store'
//没有权限要求的基本页 都可以进入
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
    meta: {
      title: '登录'
    }

  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  // 全屏可视化
  {
    path: '/fullScreen',
    component: () => import('@/views/fullScreen'),
    hidden: true
  },
  // 添加租户
  {
    path: '/sys',
    component: Layout,
    hidden: true,
    children: [
      {
        path: `postTenant`,
        name: 'postTenant',
        component: () => import('@/views/sys/tenant/postTenant.vue'),
        hidden: true,
        meta: {
          title: '添加租户',
          show: false
        }
      }
    ]
  },
  // 编辑租户
  {
    path: '/sys',
    component: Layout,
    hidden: true,
    children: [
      {
        path: `putTenant`,
        name: 'putTenant',
        component: () => import('@/views/sys/tenant/putTenant.vue'),
        hidden: true,
        meta: {
          title: '编辑租户',
          show: false
        }
      }
    ]
  },
  // 编辑租户
  {
    path: '/sys',
    component: Layout,
    hidden: true,
    children: [
      {
        path: `superAdmin`,
        name: 'superAdmin',
        component: () => import('@/views/sys/tenant/superAdmin.vue'),
        hidden: true,
        meta: {
          title: '超管管理',
          show: false
        }
      }
    ]
  },

]

// 根据权限显示的路由
export const asyncRoutes = [
  // 404 页面必须放置在最后一个页面
  // { path: '*', redirect: '/404', hidden: true }
]


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
